import Components from "./Components.js";
import List from './List.js'
export default class Input extends Components {
  constructor(options) {
    super();
    this.options = options;
  }

  render() {
    const { placeholderText, buttonText } = this.options;
    this.options.wrapEl.innerHTML += Components.InputView(
      placeholderText,
      buttonText
    );
  }

  bindEvent(){
    const oAddBtn = document.querySelector('.add-button')
    const oInput = document.querySelector('.todo-input')
    oAddBtn.addEventListener('click',handleBtnClick.bind(this,oInput),false)
  }
}

function handleBtnClick(inputDom){
  const val = inputDom.value.trim()

  if(val.length){
    List.addItem(val);
    inputDom.value = '';
  }
}
